import tool from "@/utils/tool";

export const resObjNotNull = (rule, value, callback) => {
	if (!value || value == "" || !value.id) {
		callback(new Error('不能为空'));
	} else {
		callback();
	}
};

export const amountGtZero = (rule, value, callback) => {
	if (value <= 0) {
		callback(new Error('需大于0'));
	} else {
		callback();
	}
};

export const warehouseNotNull = (rule, value, callback) => {
	let userInfo = tool.data.get("USER_INFO");
	if(!userInfo){
		callback();
	}else if(userInfo.multiWarehouse && (!value || value == "")){
		callback(new Error("不能为空"));
	}else{
		callback();
	}
};
